/**
 *  This file is part of AugeasWH.
 *
 *  AugeasWH. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AugeasWH. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AugeasWH.  If not, see <http://www.gnu.org/licenses/>.
 */

package cz.fit.vutbr.pis2012.augeaswh.persistence;

import java.io.Serializable;
import javax.persistence.*;

/**
 * The persistent class for the subjects database table.
 * 
 */
@Entity
@DiscriminatorColumn(name="type")
@Table(name="subjects")
public abstract class Subject implements Serializable, AugeasWHEntity {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	private String dic;

	private String ico;

	private String name;

	private String type;

	//bi-directional many-to-one association to BankAccount
	@JoinColumn(name="bank_account_id")
	private BankAccount bankAccount;

    public Subject() {
    }

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDic() {
		return this.dic;
	}

	public void setDic(String dic) {
		this.dic = dic;
	}

	public String getIco() {
		return this.ico;
	}

	public void setIco(String ico) {
		this.ico = ico;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	public BankAccount getBankAccount() {
		return this.bankAccount;
	}

	public void setBankAccount(BankAccount bankAccount) {
		this.bankAccount = bankAccount;
	}
	
	@Override
	public boolean equals(Object other) {
		if (other == null) return false;
		if (other == this) return true;
		if (!(other instanceof Subject)) return false;
		Subject sOther = (Subject) other;
		return (sOther.getName().equals(getName()) && 
				sOther.getId() == getId() && 
				sOther.getIco().equals(getIco()) && 
				sOther.getType().equals(getType()));
	}
}